class StockRank:
    code = ''
    name = ''
    old_price = ''
    new_price = ''
    old_weight = ''
    new_weight = ''
    ranking = ''
    price_change = ''

    def __init__(self, code, name, new_price, old_price, new_weight, old_weight, ranking):
        self.code = code
        self.name = name
        self.old_price = old_price
        self.new_price = new_price
        self.old_weight = old_weight
        self.new_weight = new_weight
        self.ranking = ranking
        self.price_change = (new_price - old_price)

def convert_2_json(obj):
    return {
        "name": obj.name,
        "code": obj.code,
        "old_price": obj.old_price,
        "new_price": obj.new_price,
        "old_weight": obj.old_weight,
        "new_weight": obj.new_weight,
        "ranking": obj.ranking,
        "price_change": obj.price_change
    }
